package com.cq.hd.order.config;

import com.cq.hd.common.config.AbstractSwagger2;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.swing.plaf.synth.Region;

@Configuration
@EnableSwagger2
public class SwaggerConfig extends AbstractSwagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("订单服务")
                .apiInfo(this.apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cq.hd.order.controller"))
//                .paths(PathSelectors.ant("/member/**"))
                .paths(PathSelectors.any())
                .build()
                .globalOperationParameters(this.buildParameter())
                .directModelSubstitute(Region.class, Integer.class);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("app订单服务API文档")
                .description("app订单服务API接口")
                .version("1.0")
                .contact(new Contact("hd-o2o", "http://127.0.0.1.com", "service@cq.com"))
                .build();
    }

}